package starter.context;

import java.util.Map;

import com.bowlong.util.MapEx;

@SuppressWarnings("unchecked")
public class RedisContext {
	final Map<String, Object> map;

	public RedisContext() {
		map = MapEx.getMap(App.ctx(), "redis");
		this.host = MapEx.getString(map, "host");
		this.port = MapEx.getInt(map, "port");
		this.maxActive = MapEx.getInt(map, "maxActive");
		this.maxIdle = MapEx.getInt(map, "maxIdle");
		this.minIdle = MapEx.getInt(map, "minIdle");
		this.maxWait = MapEx.getInt(map, "maxWait");
	}

	// JedisPoolConfig config;
	//
	// public JedisPoolConfig getJedisPoolConfig() {
	// if (config == null)
	// config = JedisEx.newJedisPoolConfig(maxActive, maxIdle, minIdle,
	// maxWait);
	// return config;
	// }
	//
	// JedisPool jedisPool;
	//
	// public JedisPool getJedisPool() {
	// JedisPoolConfig config = getJedisPoolConfig();
	// if (jedisPool == null)
	// jedisPool = JedisEx.getJedisPool(config, host, port);
	// return jedisPool;
	// }

	public final String host;
	public final int port;
	public final int maxActive;
	public final int maxIdle;
	public final int minIdle;
	public final int maxWait;
}
